package prefuse.tp.svn;

import java.util.logging.Logger;
import prefuse.action.assignment.ColorAction;
import prefuse.data.Node;
import prefuse.util.ColorLib;
import prefuse.visual.VisualItem;

/**
 * Set node fill colors
 */
public class GraphRadial_nodeColorAction extends ColorAction {
        public GraphRadial_nodeColorAction(String group) {
        	super(group, VisualItem.STROKECOLOR, ColorLib.rgb(0,255,0));
            add("_hover", ColorLib.rgb(255,0,0));
            add("ingroup('_search_')", ColorLib.rgb(255,255,255));
            add("ingroup('_focus_')", ColorLib.rgb(0,255,255));
        }
        @Override
        public int getColor(VisualItem item) {
        	Node n = (Node) item.getSourceTuple();
            if(n.getInt("type") == GraphRadial_Affectations.UE)
            	if(n.getOutDegree()< 150)
            		return ColorLib.rgb(255, 0, 0);
        	
        	
            Object o = lookup(item);
            if ( o != null ) {
                if ( o instanceof ColorAction ) {
                    return ((ColorAction)o).getColor(item);
                } else if ( o instanceof Integer ) {
                    return ((Integer)o).intValue();
                } else {
                    Logger.getLogger(this.getClass().getName())
                        .warning("Unrecognized Object from predicate chain.");
                }
            }
            return m_defaultColor;   
        }
            
                
    }